import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_purchased_subscription_status.dart';

const kApiGooglePlayPurchasedSubscriptionActiveStatusValue = 'active';
const kApiGooglePlayPurchasedSubscriptionExpiredStatusValue = 'expired';
const kApiGooglePlayPurchasedSubscriptionPausedPeriodStatusValue = 'paused';
const kApiGooglePlayPurchasedSubscriptionRevokedStatusValue = 'revoked';

class ApiGooglePlayPurchasedSubscriptionStatusDto extends Equatable {
  const ApiGooglePlayPurchasedSubscriptionStatusDto._internal({
    required this.statusString,
  });

  final String statusString;

  @override
  List<Object?> get props {
    return [
      statusString,
    ];
  }

  factory ApiGooglePlayPurchasedSubscriptionStatusDto.fromEntity(
      ApiGooglePlayPurchasedSubscriptionStatus status) {
    late final String statusString;

    if (status == ApiGooglePlayPurchasedSubscriptionStatus.active) {
      statusString = kApiGooglePlayPurchasedSubscriptionActiveStatusValue;
    } else if (status == ApiGooglePlayPurchasedSubscriptionStatus.expired) {
      statusString = kApiGooglePlayPurchasedSubscriptionExpiredStatusValue;
    } else if (status == ApiGooglePlayPurchasedSubscriptionStatus.paused) {
      statusString = kApiGooglePlayPurchasedSubscriptionPausedPeriodStatusValue;
    } else if (status == ApiGooglePlayPurchasedSubscriptionStatus.revoked) {
      statusString = kApiGooglePlayPurchasedSubscriptionRevokedStatusValue;
    }

    return ApiGooglePlayPurchasedSubscriptionStatusDto._internal(
      statusString: statusString,
    );
  }

  @override
  String toString() {
    return statusString;
  }
}
